using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Permissions;
using System.Web.Mvc;
using Pixster.Controllers.Helpers;
using Pixster.Models;

namespace Pixster.Controllers
{
    [PrincipalPermission(SecurityAction.Demand, Authenticated = true)]
    public class AdminController : Controller
    {
        private const string PHOTOS_ROOT = "/Photos";

        public ActionResult Index()
        {
            return View();
        }

        public ActionResult Sitemap()
        {
            var serverPath = Server.MapPath(PHOTOS_ROOT);

            var sitemap = ManifestHelper.GetSitemap(serverPath);

            return View(new AdminViewModel { Directories = sitemap });
        }

        public ActionResult UpdateDirectory()
        {
            return View();
        }

        [AcceptVerbs(HttpVerbs.Post)]
        public ActionResult UpdateDirectory(PixDirectory directory)
        {
            return View("Sitemap");
        }
    }
}